let list = [
  {
    id: 1,
    roleName: '剧毒术士',
    roleCode: 'judu',
    order: 1,
    status: 1,
    remark: '辅助'
  },
]

export default {
  'GET  /api/v1/role': {
    data: list,
    total: list.length,
    page: 1,
    success: true
  },
  'POST /api/v1/role/': async (req: Request, res: Response) => {
    const { roleName, roleCode, order, status, remark } = req.body as any;

    list.push({
      id: list.length + 1,
      roleName,
      roleCode,
      order,
      status,
      remark
    })
    res.send({
      success: true
    });
  },
  'PUT /api/v1/role/1': async (req: Request, res: Response) => {
    console.log('request', req)
    const { roleName, roleCode, order, status, remark } = req.body as any;

    const one = list.find(l => l.id === 1)
    if (one) {
      Object.assign(one, {
        roleName,
      roleCode,
      order,
      status,
      remark
      })
    }
    res.send({
      success: true,
      one
    });
  },
  'DELETE /api/v1/role/1': async (req: Request, res: Response) => {

    list = list.filter((l) => l.id != 1)
    res.send({
      success: true,
      list
    });
  },
};

